package com.enterpriseDigitalPlatform.controller.renshi.dept;

import com.enterpriseDigitalPlatform.anotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collection;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Dept {
    @TreeId()
    private Integer id;
    @TreeName()
    private String name;
    @TreeParentId()
    private Integer pid;
    @TreeParentName
    private String pname;
    private Integer level;
    @TreeParentIds
    private String pids;
    private Integer isDel;
    private String createdAt;
    private String updatedAt;
    @TreeList()
    private Collection<Dept> children;

    public int getParIdFirst() {
        if (pids == null || pids.isEmpty()) {
            return 0;
        }
        return Integer.parseInt(pids.split("-")[0]);
    }
}

